<template>
	<view id="main">
		<view class="property">
			<text>总资产 \n0.00</text>
			<text>最新收益\n0.00</text>
		</view>
		<view class="content">
			<view class="menu">
				<view class="top">
					<view class="item" v-for="item in navigation" :key="item.id">
						<navigator url="/pages/regular/regular">
							<image :src="item.imageSrc" mode="" class="pic"></image>
						</navigator>
						<text class="text">{{item.name}}</text>
					</view>
				</view>
			</view>
			<!-- 行情 -->
			<view id="market">
				<text class="comm-title">行情</text>
				<view class="item">
					<view class="market-item" v-for="(item,index) in 3" :key="index">
						<text>深圳指数</text>
						<text>14828.80</text>
						<text>-41.86 -0.28%</text>
					</view>
				</view>
				<view class="advertising">
					<text>新春福利 速领50元红包</text>
					<text>福利:领1288元红包</text>
				</view>
			</view>
			<!--热门基金 -->
			<view id="fund">
				<text class="comm-title">热门基金</text>
				<view class="tab">
					<view class="tab-item" :class="{isActive:activeTab==item.name}" v-for="item in tabItem"
						:key="item.id" @tap="activeTab=item.name;">
						{{item.name}}
					</view>
				</view>
				<view class="fund-main">
					<view class="fund-item" v-for="(item,index) in 3" :key="index">
						<text>深圳指数</text>
						<text>14828.80</text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				navigation: [],
				tabItem: [{
						id: 1,
						name: '推荐'
					},
					{
						id: 2,
						name: '稳健之选'
					},
					{
						id: 3,
						name: '长跑之选'
					},
					{
						id: 4,
						name: '港股精选'
					}
				],
				activeTab: '推荐'
			}
		},
		onLoad() {
			this.getNavigation();
		},
		onShow() {
			const app = getApp().globalData;
			console.log(app.userInfo);
		},
		methods: {
			async getNavigation() {
				const res = await this.$http.center.getNavigationInfo();
				if (res.code == 200) {
					this.navigation = res.data
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		position: relative;
	}

	.property {
		display: flex;
		height: 300rpx;
		justify-content: space-evenly;
		border-top-left-radius: 50rpx;
		background-color: #ffe3c0;
		box-sizing: border-box;
		padding-top: 44rpx;
	}

	.content {
		width: 100%;
		background-color: white;
		border-top-left-radius: 50rpx;
		position: absolute;
		top: 148rpx;
		box-sizing: border-box;
		padding-top: 44rpx;
		padding-left: 24rpx;
		padding-right: 24rpx;
	}

	.menu {
		.top {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-around;

			.item {
				width: 140rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-top: 30rpx;

				.pic {
					width: 88rpx;
					height: 88rpx;
				}

				.text {
					margin-top: 18rpx;
					font-size: 24rpx;
					color: #666666;
				}
			}
		}
	}

	.comm-title {
		font-size: 36rpx;
		margin-left: 24rpx;
		height: 40rpx;
		position: relative;
		font-weight: bold;

		&::before {
			content: "";
			display: inline-block;
			width: 10rpx;
			height: 34rpx;
			background-color: #3476fe;
			margin-right: 20rpx;
			position: absolute;
			left: -24rpx;
			top: 8rpx;
			border-radius: 8rpx;
		}
	}

	#market {
		margin-top: 40rpx;

		.item {
			margin-top: 22rpx;
			box-shadow: 0px 0px 5px #ececec;
			box-sizing: border-box;
			padding: 24rpx;
			display: flex;
			// justify-content: space-between;
			justify-content: space-around;

			.market-item {
				display: flex;
				flex-direction: column;
				width: 170rpx;
				justify-content: center;

				text {
					text-align: center;

					&:nth-child(1) {
						font-size: 28rpx;
					}

					&:nth-child(2) {
						font-size: 36rpx;
						margin-top: 30rpx;
						margin-bottom: 14rpx;
						color: #f85656;
						font-weight: bold;
					}

					&:nth-child(3) {
						font-size: 24rpx;
						color: #f85656;

					}
				}
			}

		}

		.advertising {
			height: 60rpx;
			background-color: #eaf1fe;
			font-size: 24rpx;
			line-height: 60rpx;
			padding-left: 36rpx;

			text {

				// line-height: 60rpx;
				&:nth-child(2) {
					margin-left: 70rpx;
				}
			}
		}
	}

	#fund {
		margin-top: 40rpx;

		.tab {
			display: flex;
			margin-top: 20rpx;

			.tab-item {
				// width: 114rpx;
				// height: 48rpx;
				padding: 10rpx;
				border-radius: 8rpx;
				font-size: 28rpx;
				color: #c5c5c5;
				margin-right: 40rpx;
			}

			.isActive {
				color: white;
				background-color: #3476f1;
			}

		}

		.fund-main {
			margin-top: 22rpx;
			box-shadow: 0px 0px 5px #ececec;
			box-sizing: border-box;
			padding: 24rpx;
		}
	}
</style>
